package com.wdd.libhttp

import android.app.Application
import com.lzy.okgo.OkGo
import com.lzy.okgo.cache.CacheEntity
import com.lzy.okgo.cache.CacheMode
import com.wdd.stetho.StethoUtils
import okhttp3.OkHttpClient

/**
 *
 * @ProjectName:    OwnTool
 * @Package:        com.wdd.libhttp
 * @ClassName:      HttpManager
 * @Description:     初始化请求模块
 * @Author:         王丹丹
 * @CreateDate:     2019/12/18 13:36
 * @UpdateUser:     更新者
 * @UpdateDate:     2019/12/18 13:36
 * @UpdateRemark:   更新说明
 * @Version:        1.0
 */
class HttpManager {
    companion object {
        fun initHttp(application: Application, httpClient: OkHttpClient? = null) {
            StethoUtils.initStetho(application)
            OkGo.getInstance().init(application).setOkHttpClient(httpClient)
                .setCacheMode(CacheMode.NO_CACHE)  //全局统一缓存模式，默认不使用缓存，可以不传
                .setCacheTime(CacheEntity.CACHE_NEVER_EXPIRE)  //全局统一缓存时间，默认永不过期，可以不传
                .setRetryCount(2) //全局统一超时重连次数，默认为三次
        }
    }
}